@extends('home.layout.layout')
@section('tittle','个人中心')
@section('css')
    <link rel="stylesheet" type="text/css" href="{{asset('/HomeCss/css/common.css')}}"/>
    <link rel="stylesheet" type="text/css" href="{{asset('/HomeCss/css/index.css')}}">
    <link rel="stylesheet" type="text/css" href="{{asset('/HomeCss/css/ucenter.css')}}">
@endsection
@section('con')
	<div class="ucenter">
    <div class="leftnnav">
    <dl>
        <dt>订单中心</dt>
        <dd><a href="/order/lists" title="我的订单" >我的订单</a></dd>
        <dd><a href="/order/lists/c" title="评价晒单">评价晒单</a></dd>
    </dl>
    <dl>
        <dt>个人中心</dt>
        <dd><a href="/installment/index" title="我的好乐买分期">我的好乐买分期</a></dd>
        <dd><a href="{{asset('/home/collect/index')}}" title="我的收藏">我的收藏</a></dd>
        <dd><a href="" title="我的优惠券">我的优惠券</a></dd>
        <dd><a href="/member/integral" title="我的积分">我的积分</a></dd>
        <dd><a href="/memberaddress/address" title="收货地址管理">收货地址管理</a></dd>
        <dd><a href="/home/umessage/index" title="实名认证">实名认证</a></dd>
                    <dd><a href="{{asset('/home/umessage/index')}}" class="cur" title="账号安全">账号安全</a></dd>
                <dd><a href="/inbox/index" title="我的消息">我的消息</a></dd>
    </dl>
    <dl>
        <dt>客户服务</dt>
        <dd><a href="{{asset('/home/umessage/member')}}" title="用户反馈">用户反馈</a></dd>
        <dd><a href="/priceprotect" title="价额保护">价格保护</a></dd>
    </dl>
</div>    
    <div class="rMain" style="min-height:599px;">
    	@if(session('error'))
    		{{session('error')}}
    	@endif
			<div class="rmainTitle">
				<h3>账号安全</h3>
			</div>
			<div class="userzh-box">
				<div class="userzh-wrap">
					<b class="zhy-icon"></b>
					<span class="zh-titl">登录密码</span><span class="zhline">|</span><span class="zh-info">互联网账号存在被盗风险，建议您定期更改密码以保护账户安全。</span>
					<span class="zh-allbtn"><a id="mima" class="zh-updatebtn" href="javascript:void(0)">修改</a>
					</span>
				</div>	
				<div class="userzh-wrap">
					<b @if($status == 1) class="zhy-icon" @else class="zhn-icon" @endif></b>
					<span class="zh-titl">邮箱验证</span><span class="zhline">|</span><span class="zh-info">您验证的邮箱：<b> @if($mail) {{$mail}} @else ******* @endif </b></span>
					<span class="zh-allbtn">
						@if($status == 1)
						<span class="zh-allbtn"><a id="youxiang" class="zh-updatebtn" href="javascript:void(0)">修改</a>
						@else
						<a id="youxiang" class="zh-yanztn" href="javascript:void(0)" value="youxiang_check">立即验证</a>
						@endif
					</span>
				</div>	
			
			</div>
		</div>

</div>
<div id="dialog1" style="display:none">
<div class="zh-shade"></div>
<div class="zhdailog" style="height:auto;">
	<b id="zhclose" class="zhclose"></b>
	<div class="conbox">
		<h3>修改密码</h3>
		<form  method="post" action="/home/umessage/editpw" enctype="multipart/form-data">
		
		<p class="conyan">
			<span id="msg-yuan" class="loginmsg"></span>
		</p>
		<p class="conyan">
			<span class="logintxt">新密码：</span><input id="newupwd" name="newupwd" placeholder="请输入新的登录密码" autocomplete="off" type="password">
		</p>
		<br>
		<p class="conyan">
			<span class="logintxt"></span><input id="newupwds" name="newupwds" placeholder="请再次输入新登录密码" autocomplete="off" type="password">
		</p>
		<p class="conyan">
			<span id="upwError" class="loginmsg" style="display:block"></span>
		</p>
		{{csrf_field()}}
		<p class="conyan">密码长度6~16位，建议使用数字、字母和符号组合</p>
		<button id="passwdbtn1" class="next-btn" value="提交" type="submit" style="color:#999">提交</button>
		</form>		
	</div>
</div>
</div>



<div id="dialog2" style="display:none">
<div class="zh-shade"></div>
<div class="zhdailog">
	<b id="zhclose" class="zhclose"></b>
	<div class="conbox">
		<h3>验证邮箱</h3>

		<p class="conyan">
			<span class="logintxt">邮箱：</span><input id="email" name="email" placeholder="请输入邮箱" type="text">
		</p>
		<p class="conyan">
			<span id="msg-email" class="loginmsg"></span>
		</p>	
		<input id="emailbtn1" class="next-btn" style="margin-bottom:0;" value="下一步" type="submit">
	
	</div>
</div>
</div>


@endsection
@section('js')
	<script type="text/javascript">
	//绑定弹窗按钮
	$('#mima').click(function(){
	
		$('#dialog1').css('display','block');
	})

	$('#youxiang').click(function(){
	
		$('#dialog2').css('display','block');
	})

	
	//绑定关闭弹窗按钮
	$('.zhclose').click(function(){
		$('#dialog1').css('display','none');
		$('#dialog2').css('display','none');

	})

	$('form').submit(function(){
		$('#dialog1').css('display','none');
		

	})
	//邮箱验证
    var MAIL = false;

	$('#emailbtn1').click(function(){
		  //触发所有的丧失焦点事件
        $('input').trigger('blur');
        //判断是否全部成功
        if(MAIL){
        	//发送ajax
            var email = $('#email').val();
			$.get('/home/umessage/sendmails',{email:email},function(data){
				if(data == 1){

					alert('发送成功');
				}else if(data == 0){
					alert('邮箱已存在');
				}else{
                    alert('发送失败');
                }
			})
        }else{
        	$('#upwError').html('密码不能为空');
        	return false;
        }
		
		
		$('#dialog2').css('display','none');
	})
	 
	//声明全局变量
    var UPW = false;
    var REUPW = false;
    //绑定表单事件
    $('#passwdbtn1').click(function(){
       
        //触发所有的丧失焦点事件
        $('input').trigger('blur');
        //判断是否全部成功
        if(UPW && REUPW){
            return true;
        }

        return false;
        
    	})

    //绑定丧失焦点事件
    $('#newupwd').blur(function(){
    
        //获取值
        var newupwd = $('#newupwd').val();
       
        //清除样式
        $('#upwError').html('');
        if(!newupwd){
            $('#upwError').html('密码不能为空');
            UPW =  false;
        }else{
            var reg  = /\w{6,18}/;
            if(!reg.test(newupwd)){
                $('#upwError').html('密码格式不正确');
                UPW = false;
            }else{
                 UPW = true;
            }
        }

    })
    
    //绑定丧失焦点事件
    $('#newupwds').blur(function(){
        //获取值
        var newupwds = $('#newupwds').val();
        var newupwd = $('#newupwd').val();
        //清除样式
        $('#upwError').html('');
        if(newupwds != newupwd){
           $('#upwError').html('两次密码输入不一致'); 
           REUPW = false;
        }else{
            REUPW = true;
        }
    }) 

    
    //绑定邮箱丧失焦点事件
    $('#email').blur(function(){
    
        //获取值
        var email = $('#email').val();
        //清除样式
        $('#msg-email').html('');
        if(!email){
            $('#msg-email').html('邮箱不能为空');
            MAIL =  false;
        }else{
            var reg  = /\w{6,18}/;
            if(!reg.test(email)){
                $('#msg-email').html('邮箱格式不正确');
                MAIL = false;
            }else{
                 MAIL = true;
            }
        }

    });
    </script>
    <script type="text/javascript" src="{{asset('/HomeCss/js/topslide.js')}}"></script>
    <script type="text/javascript" src="{{asset('/HomeCss/js/scrolltotop.js')}}"></script>
    <script type="text/javascript" src="{{asset('/HomeCss/js/timer.js')}}"></script>
    <script type="text/javascript" src="{{asset('/HomeCss/js/traffic.js')}}" async></script>
    <script type="text/javascript" src="{{asset('/HomeCss/js/jquery-1.8.3.min.js')}}"></script>
@endsection